﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks.Dataflow;

namespace NewSolution
{
    public class CompareBlock
    {
        public IEnumerable<(bool, int)> Comparison(byte[] frameA, byte[] frameB, int frameNumber)
        {
            if (frameA.Length != frameB.Length)
            {
                yield return (false, frameNumber);
            }

            for (int i = 0; i < frameA.Length; i++)
            {
                if (frameA[i] != frameB[i])
                {
                    yield return (false, frameNumber);
                    yield break;
                }
            }
            yield return (true, frameNumber);
        }

        public TransformBlock<Tuple<(byte[], int), (byte[], int)>, IEnumerable<(bool, int)>> CreateTransformBlock()
        {
            return new TransformBlock<Tuple<(byte[], int), (byte[], int)>, IEnumerable<(bool, int)>>(
                input =>
                {
                    var (frameA, frameB) = input;
                    var compareBlock = new CompareBlock();
                    return compareBlock.Comparison(frameA.Item1, frameB.Item1, frameA.Item2);
                });
        }

       
    }
}